package com.ap.core.domain;

import com.ap.core.cxf.jaxb.rtp.AmountType;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.joda.time.LocalDate;

import javax.persistence.*;

/**
 * User: Ranjit.Singh
 */
@Entity
@Table(name = "T_ORDER_AMOUNT_DETAIL")
@AttributeOverride(name = "id",column = @Column(name = "order_amount_detail_id"))
@TypeDef(name = "id", typeClass = Long.class)
public class OrderAmountDetail extends Identifiable<Long>{

    @Column(name = "AMOUNT_TYPE_CODE")
    @Enumerated(EnumType.STRING)
    private AmountType amountType;

    @Embedded
    @AttributeOverride(name = "value", column = @Column(name = "VALUE"))
    private Amount value;

    @Embedded
    @AttributeOverride(name = "value", column = @Column(name = "RATE"))
    private Rate rate;

    @Column(name = "ap_txn_id")
    private String apTransactionId;

    @Column(name = "reconciliation_cycle_id")
    private String  reconciliationCycleId;

    @Column(name = "reconciliation_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
    private LocalDate reconciliationDate;

    private OrderAmountDetail(){}

    public OrderAmountDetail(Long id, Amount value, String apTransactionId, String  reconciliationCycleId, LocalDate reconciliationDate) {
        setId(id);
        this.value = value;
        this.apTransactionId = apTransactionId;
        this.reconciliationCycleId = reconciliationCycleId;
        this.reconciliationDate = reconciliationDate;
    }

    public void setAmountType(AmountType amountType) {
        this.amountType = amountType;
    }

    public void setRate(Rate rate) {
        this.rate = rate;
    }

    public AmountType getAmountType() {

        return amountType;
    }

    public Rate getRate() {
        return rate;
    }

    public Amount getValue() {
        return value;
    }

    public String getApTransactionId() {
        return apTransactionId;
    }

    public String getReconciliationCycleId() {
        return reconciliationCycleId;
    }

    public LocalDate getReconciliationDate() {
        return reconciliationDate;
    }
}